package com.tnsw.noxnox.settopbox;

import com.tnsw.coreutils.AsyncManager;
import com.tnsw.noxnox.R;
import com.tnsw.noxnox.R.layout;
import com.tnsw.noxnox.R.menu;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;
import android.view.Menu;
import android.widget.TextView;

public class SetTopBoxActivity extends Activity {

	private String tag = "SetTopBoxActivity";
	private AsyncManager asyncManager;
	private TextView lblMode;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Log.d(tag, "onCreated()");
		this.asyncManager = AsyncManager.getInstance();
		setContentView(R.layout.activity_set_top_box);
		
		this.lblMode = (TextView) this.findViewById(R.id.lblMode);
		
		String currentMode = "xx";
		
		try {
			SharedPreferences settings = this.getSharedPreferences("SelectModeActivity", MODE_PRIVATE);
			currentMode = settings.getString("mode", "");
			
			this.lblMode.setText("Mode:" + currentMode);
			
		} catch (Exception e) {
			Log.e(tag, "detectSharedPreference() - " + e.toString(), e);
			this.asyncManager.appendNetworkLog("Error detectSharedPreference() - " + e.toString());
			
		}
		
		if (AsyncManager.isServiceRunning(this, com.tnsw.noxnox.settopbox.STBService.class.getName()) == false) {
			Intent intent = new Intent(this, com.tnsw.noxnox.settopbox.STBService.class);
			this.startService(intent);			
		}

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.set_top_box, menu);
		return true;
	}

}
